<?php

class LoginView {

	private $m_username = "username";
	private $m_password = "password";
	private $m_logout = "logout";
	// Genom GET kan man anropa formuläret i andra funktioner
	public function DoLoginBox() {

		$loginForm = "
		<form method='GET'>
  		Username: <input type='text' name='" . $this -> m_username . "' size='15' /><br />
  		Password: <input type='password' name='" . $this -> m_password . "'  size='15' /><br />
  		<p><input type='submit' value='Login'/></p>
  		</form>";
		return $loginForm;
	}

	public function DoLogoutBox() {
		$logoutButton = "<form method='GET'>
		<input type='hidden' value='active' name='" . $this -> m_logout . "'/>
		<input type='submit' value='Logout'/></form>";
		return $logoutButton;
	}

	public function GetUserName() {
		if (isset($_GET[$this -> m_username]) == true) {
			//return the variable
			return $_GET[$this -> m_username];
		} else {
			return NULL;
		}
	}

	public function GetPassword() {
		if (isset($_GET[$this -> m_password]) == true) {
			//return the variable
			return $_GET[$this -> m_password];
		} else {
			return NULL;
		}
	}

	// Så länge värdena som mottas inte är null så får man inte felmedellande
	public function TriedToLogin() {
		if (($this -> GetUserName() != NULL) && ($this -> GetPassword() != NULL)) {
			return true;
		} else {
			return false;
		}
	}

	// anropar elementen för knappen och via isset kollar man om den trycks på
	public function TriedToLogout() {
		if (isset($_GET[$this -> m_logout]) == true) {
			return true;
		} else {
			return false;
		}
	}

}
?>
